fix: stop guard treats stale task.json as expired after 60 minutes#256
fix: stop guard treats stale task.json as expired after 60 minutes#256nikosbosse merged 2 commits intomainfrom
Conversation
3284094 to
1ef58f8
Compare
If a Claude Code session crashes or is force-quit before everyrow_progress polling completes, ~/.everyrow/task.json stays with status "running" forever. The SessionEnd hook doesn't always fire on force-quit, so the stale file blocks ALL future sessions from stopping. Add a staleness check using file mtime (which is updated on every everyrow_progress poll). If no poll has happened in 60 minutes, the session is likely dead — remove the file and allow the stop. Using mtime rather than started_at means long-running tasks that are still being actively polled won't be affected. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1ef58f8 to
408d745
Compare
rgambee
left a comment
There was a problem hiding this comment.
Thanks. I would like to get rid of this stop guard soon, but this is a helpful incremental improvement.
| fi | ||
|
|
||
| TASK_FILE="$HOME/.everyrow/task.json" | ||
| STALE_SECONDS=3600 # 60 minutes |
There was a problem hiding this comment.
This could probably be lowered significantly. The file is supposed to update every 15 seconds or so. 5 minutes or even 1 minute of inactivity is likely a sign that it can be ignored.
|
Changed to 4 minutes. Will merge soon |
| fi | ||
|
|
||
| TASK_FILE="$HOME/.everyrow/task.json" | ||
| STALE_SECONDS=240 # 4 minutes |
There was a problem hiding this comment.
Bug: The STALE_SECONDS variable is set to 240 (4 minutes), but the documented intent is 60 minutes, which could cause premature termination of active sessions.
Severity: CRITICAL
Suggested Fix
In everyrow-stop-guard.sh, change the value of STALE_SECONDS from 240 to 3600 to align with the documented 60-minute timeout.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: everyrow-mcp/scripts/everyrow-stop-guard.sh#L16
Potential issue: The script `everyrow-stop-guard.sh` sets a timeout of 4 minutes
(`STALE_SECONDS=240`) to determine if a session is stale. However, the PR description
and commit message state the intended timeout is 60 minutes. With polling happening
approximately every 12 seconds, any task experiencing a delay longer than 4 minutes due
to network issues or system load will be incorrectly terminated. This aggressive timeout
contradicts the intended safety margin and will lead to the premature termination of
potentially active user sessions.
Did we get this right? 👍 / 👎 to inform future reviews.
Summary
~/.everyrow/task.jsonwith"status": "running"blocks all Claude Code sessions from stopping indefinitelyeveryrow_progresspoll) — if no poll has happened in 60 minutes, the session is likely dead, so it removes the file and allows the stopstarted_atmeans long-running tasks that are still being actively polled won't be affectedeveryrow_progresspolling completes,SessionEnddoesn't always fire, leaving a permanent stale state fileTest plan
started_at(matches real MCP server output)bash everyrow-mcp/tests/test_hook_stop_guard.shbash everyrow-mcp/tests/test_hook_results.sh🤖 Generated with Claude Code